package com.cloud.basic.jettyWebsocket;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler;

/**
 * @program: basic
 * @description:
 * @author: Cloud
 * @create: 2021/5/23 23:41:34
 */
@Slf4j
public class test {
    public static void main(String args[])
    {
        Server server = new Server(7778);

        /* webSocket的handler */
        WebSocketHandlerTest test = new WebSocketHandlerTest();

        ContextHandler context = new ContextHandler();
        /* 路径 */
        context.setContextPath("/test");
        context.setHandler(test);

        server.setHandler(context);
        try
        {
            log.info("jetty-websocket开始启动！");
            /* 启动服务端 */
            server.start();
            server.join();
        }
        catch (Exception e)
        {

            e.printStackTrace();
        }

    }
}
